import { Component, OnInit, Input, Output, EventEmitter} from '@angular/core';
import { NavController, NavParams,AlertController,ModalController } from 'ionic-angular';
import { ChoosePointsPage } from '../choose-points/choose-points';
import { Mistake } from '../mistake';
import { MistakeService } from '../mistake.service';
import { SameExamplePage } from '../same-example/same-example';
import { showMistakeByTimePage } from '../show-mistakeByTime/show-mistakeByTime'; 


@Component({
    selector: 'page-show-mistakeByPoint',
    templateUrl: 'show-mistakeByPoint.html',
    providers:[MistakeService],
   
  })
  export class ShowMistakeByPointPage implements OnInit{
      currentPoint:string;
      mistakeListByPoints: Mistake[];
      constructor(
          private navparams: NavParams,
          public navCtrl: NavController,
          public mistakeService: MistakeService,
      ){
          this.mistakeListByPoints = [];
      }
      ngOnInit():void{
        this.currentPoint = this.navparams.get("currentPoint");
        this.getMistakesByPoint();
        console.log("pointList"+this.mistakeListByPoints);
      }
      getMistakesByPoint(){
        var url = "http://localhost:8080/mistake/getMistakesByPoint?currentPoint="+this.currentPoint;
        console.log(url);
        return this.mistakeService.getMistakesByPoints(url).then(mistakeList=>(
          this.mistakeListByPoints = mistakeList)
          //this.currentMistake = mistakeList[0],
         // this.collectFlags.push(false))
        )}
        gotoShowMistakePage(mistake: Mistake){
            console.log(mistake.misId);
            this.navCtrl.push(showMistakeByTimePage,{currentMistakeId : mistake.misId});
          }
    }
